<?php namespace Admin\Controller; 

// use Hdphp\Controller\Controller;
use Admin\Model\Goods;

class RecyleBinController extends AuthController
{
	protected $db;

	//构造函数
	public function __init()
	{
		$this->db = new Goods;
	}
	
    //动作
    public function index(){
    	$data = $this->db->where('is_delete',1)->get();
    	View::with('delGoods',$data);
        View::make();
    }

    public function restore()
    {
    	$goods_id = Q('get.goods_id');		
		if($data = $this->db->find($goods_id))
		{
			$data['is_delete'] = '0';
			if($this->db->save($data))
			{
            	View::success('还原成功',U('Goods/index'));
        	}else{
            	View::error($this->db->getError());
        	}
		}    	
    }

    public function del()
    {
    	if($this->db->where('goods_id',Q('get.id'))->delete())
    	{
            View::success('商品已彻底删除',U('RecyleBin/index'));
        }else{
            View::error($this->db->getError());
        }
    }
}
